﻿namespace PMS.Client.FrmAdmin
{
    using PMS.BLL;
    using PMS.Common;
    using PMS.Model;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmAdd : Form
    {
        private AdminBLL adminbll = new AdminBLL();
        private Button btnCancel;
        private Button btnSave;
        private IContainer components = null;
        private CheckBox IsEnable;
        private Label label1;
        private Label label2;
        private Label label3;
        private Label label4;
        private TextBox LoginName;
        private DateTimePicker outUseDate;
        private TextBox Password;
        private RoleBLL rolebll = new RoleBLL();
        private ComboBox RoleID;

        public FrmAdd()
        {
            this.InitializeComponent();
            this.RoleID.DataSource = this.rolebll.GetList();
            this.RoleID.DisplayMember = "RoleName";
            this.RoleID.ValueMember = "RoleID";
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Admin admin2 = new Admin {
                LoginName = this.LoginName.Text,
                Password = DESEncrypt.GetMd5(this.Password.Text),
                RoleID = (this.RoleID.SelectedItem as Role).RoleID,
                OutUseDate = this.outUseDate.Value,
                IsEnable = this.IsEnable.Checked
            };
            Admin model = admin2;
            if (this.adminbll.Add(model) > 0)
            {
                base.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("用户添加失败！");
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(FrmAdd));
            this.label1 = new Label();
            this.RoleID = new ComboBox();
            this.label2 = new Label();
            this.btnCancel = new Button();
            this.btnSave = new Button();
            this.LoginName = new TextBox();
            this.Password = new TextBox();
            this.label4 = new Label();
            this.label3 = new Label();
            this.outUseDate = new DateTimePicker();
            this.IsEnable = new CheckBox();
            base.SuspendLayout();
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x2c, 0x1c);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x35, 12);
            this.label1.TabIndex = 0;
            this.label1.Text = "用 户 名";
            this.RoleID.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.RoleID.DropDownStyle = ComboBoxStyle.DropDownList;
            this.RoleID.FlatStyle = FlatStyle.Flat;
            this.RoleID.FormattingEnabled = true;
            this.RoleID.Location = new Point(0x67, 0x65);
            this.RoleID.Name = "RoleID";
            this.RoleID.Size = new Size(0xc0, 20);
            this.RoleID.TabIndex = 14;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(0x2c, 0x68);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x35, 12);
            this.label2.TabIndex = 13;
            this.label2.Text = "角    色";
            this.btnCancel.BackColor = Color.White;
            this.btnCancel.FlatStyle = FlatStyle.Popup;
            this.btnCancel.Location = new Point(220, 0xd0);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 12;
            this.btnCancel.Text = "取消";
            this.btnCancel.UseVisualStyleBackColor = false;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnSave.BackColor = Color.White;
            this.btnSave.FlatStyle = FlatStyle.Popup;
            this.btnSave.Location = new Point(0x67, 0xd0);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new Size(0x4b, 0x17);
            this.btnSave.TabIndex = 11;
            this.btnSave.Text = "保存";
            this.btnSave.UseVisualStyleBackColor = false;
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            this.LoginName.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LoginName.BorderStyle = BorderStyle.FixedSingle;
            this.LoginName.Location = new Point(0x67, 0x1a);
            this.LoginName.Name = "LoginName";
            this.LoginName.Size = new Size(0xc0, 0x15);
            this.LoginName.TabIndex = 10;
            this.Password.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.Password.BorderStyle = BorderStyle.FixedSingle;
            this.Password.Location = new Point(0x67, 0x40);
            this.Password.Name = "Password";
            this.Password.Size = new Size(0xc0, 0x15);
            this.Password.TabIndex = 0x10;
            this.label4.AutoSize = true;
            this.label4.Location = new Point(0x2c, 0x42);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x35, 12);
            this.label4.TabIndex = 15;
            this.label4.Text = "密    码";
            this.label3.AutoSize = true;
            this.label3.Location = new Point(0x2c, 0x8f);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x35, 12);
            this.label3.TabIndex = 0x11;
            this.label3.Text = "过期时间";
            this.outUseDate.Location = new Point(0x67, 0x89);
            this.outUseDate.Name = "outUseDate";
            this.outUseDate.Size = new Size(0xc0, 0x15);
            this.outUseDate.TabIndex = 0x12;
            this.IsEnable.AutoSize = true;
            this.IsEnable.Location = new Point(0x67, 0xb0);
            this.IsEnable.Name = "IsEnable";
            this.IsEnable.Size = new Size(0x30, 0x10);
            this.IsEnable.TabIndex = 0x13;
            this.IsEnable.Text = "启用";
            this.IsEnable.UseVisualStyleBackColor = true;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            base.ClientSize = new Size(0x16e, 0xf3);
            base.Controls.Add(this.IsEnable);
            base.Controls.Add(this.outUseDate);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.Password);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.RoleID);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnSave);
            base.Controls.Add(this.LoginName);
            base.Controls.Add(this.label1);
            this.Cursor = Cursors.Default;
            this.DoubleBuffered = true;
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FrmAdd";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "添加用户";
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

